package cn.hiapi.shopkeeper.service.order;

import cn.hiapi.basic.jpa.pageable.QueryWrapper;
import cn.hiapi.basic.service.AbsBasicService;
import cn.hiapi.shopkeeper.entity.order.ActivityOrder;
import cn.hiapi.shopkeeper.entity.order.ActivitySolitaireOrder;
import cn.hiapi.shopkeeper.jpa.order.ActivitySolitaireOrderJpa;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author AdinZ
 * @date 2023/1/12 12:00
 */
@Service
public class ActivitySolitaireOrderService extends AbsBasicService<ActivitySolitaireOrderJpa, ActivitySolitaireOrder, Long> {


    /**
     * 支付成功回调
     *
     * @param order
     */
    @Transactional
    public void payCallback(ActivityOrder order) {
        ActivitySolitaireOrder solitaireOrder = new ActivitySolitaireOrder();
        solitaireOrder.setShopId(order.getShopId());
        solitaireOrder.setBuyerId(order.getBuyerId());
        solitaireOrder.setOid(order.getId());
        solitaireOrder.setAid(order.getAid());
        solitaireOrder.setMoney(order.getTotalMoney());
        solitaireOrder.setNumber(order.getNumber());
        solitaireOrder.setTitle(order.getTitle());
        this.save(solitaireOrder);
    }

    public List<ActivitySolitaireOrder> findByAid(long aid) {
        return this.findList(new QueryWrapper().eq("aid", aid));
    }
}
